package com.wjk.cms;

import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.boot.builder.SpringApplicationBuilder;
import org.springframework.boot.web.servlet.support.SpringBootServletInitializer;
import org.springframework.scheduling.annotation.EnableScheduling;
import org.springframework.web.servlet.config.annotation.ResourceHandlerRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;

/**
 * @author WUGN
 * @des
 * @date 2021/9/11 16:03
 */
@Slf4j
@EnableScheduling
@SpringBootApplication
public class Application  extends SpringBootServletInitializer implements WebMvcConfigurer {
    @Value("${app.upload-folder-path}")
    private String uploadFolderPath;

    public static void main(String[] args) {
        System.setProperty("es.set.netty.runtime.available.processors","false");
        SpringApplication.run(Application.class,args);
    }

    @Override
    public void addResourceHandlers(ResourceHandlerRegistry registry) {
        log.info("addResourceHandlers: " + uploadFolderPath);
        registry.addResourceHandler("/File/**").addResourceLocations("file:" + uploadFolderPath + "/");
    }

    @Override
    protected SpringApplicationBuilder configure(SpringApplicationBuilder builder) {
        return builder.sources(Application.class);
    }

}
